#!/usr/bin/env python3

import time

def consumer(name):
    """
    消费者
    """
    print("%s 准备吃饭啦!" % name)
    while True:
        rice = yield
        print("开始[%s]了,[%s]已经来了!" % (rice, name))


def producer():
    """
    生产者
    """
    c = consumer('A')
    c2 = consumer('B')
    c.__next__()
    c2.__next__()
    print("吃饭开始...")
    for iin range(10):
        time.sleep(1)
        print("有两人在吃饭")
        c.send(i)
        c2.send(i)


producer()
